package com.artron.mediaartron.data.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.artron.mediaartron.R;
import com.artron.mediaartron.data.production.FrameConstant;

/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-09-22.
 */

public class ImageData implements Parcelable {

    private int frameResourceId;

    private String contentImage;

    private int defaultResourceId;

    private int frameNot9ResourceId;

    private float height;

    private float width;

    public ImageData(int frameResourceId, int frameNot9ResourceId, String contentImage) {
        this(frameResourceId, frameNot9ResourceId);
        this.contentImage = contentImage;
    }

    public ImageData(int frameResourceId, int frameNot9ResourceId, float frameWidth, float frameHeight) {
        this(frameResourceId, frameNot9ResourceId);
        this.height = frameHeight - FrameConstant.BLANK_CUSTOM_MADE;
        this.width = frameWidth - FrameConstant.BLANK_CUSTOM_MADE;
    }

    public ImageData(int frameResourceId, int frameNot9ResourceId) {
        this.frameResourceId = frameResourceId;
        this.frameNot9ResourceId = frameNot9ResourceId;
        this.defaultResourceId = R.drawable.ic_default_image;
    }

    public int getFrameResourceId() {
        return frameResourceId;
    }

    public int getFrameNot9ResourceId() {
        return frameNot9ResourceId;
    }

    public String getContentImage() {
        return contentImage;
    }

    public int getDefaultResourceId() {
        return defaultResourceId;
    }

    public void setContentImage(String contentImage) {
        this.contentImage = contentImage;
    }


    public float getHeight() {
        return height;
    }

    public void setHeight(float height) {
        this.height = height;
    }

    public float getWidth() {
        return width;
    }

    public void setWidth(float width) {
        this.width = width;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.frameResourceId);
        dest.writeString(this.contentImage);
        dest.writeInt(this.defaultResourceId);
        dest.writeFloat(this.height);
        dest.writeFloat(this.width);
    }

    protected ImageData(Parcel in) {
        this.frameResourceId = in.readInt();
        this.contentImage = in.readString();
        this.defaultResourceId = in.readInt();
        this.height = in.readFloat();
        this.width = in.readFloat();
    }

    public static final Parcelable.Creator<ImageData> CREATOR = new Parcelable.Creator<ImageData>() {
        @Override
        public ImageData createFromParcel(Parcel source) {
            return new ImageData(source);
        }

        @Override
        public ImageData[] newArray(int size) {
            return new ImageData[size];
        }
    };
}
